define(['jquery', 'vue', 'common', 'ELEMENT'], function($, Vue, common, ELEMENT) {
    const Controller = {
        index: function () {
            const {createApp, ref, onMounted} = Vue
            const app = createApp({
                setup(){
                    const adminList = ref({
                        total:0,
                        rows:[],
                        seachObj:[
                            {
                                name:"order",
                                value:"asc",
                                is_show:false
                            }
                        ]
                    })
                    const getIndex = ()=>{
                        common.loadingIndexData(adminList.value).then(res=>{
                            if(res.code==1){
                                adminList.value.total = res.data.total
                                adminList.value.rows = res.data.rows
                            }
                        })


                        // common.sendGet('index',{
                        //     sort:"id",
                        //     order:"asc"
                        // },true).then(res=>{
                        //     if(res.code==1){
                        //         adminList.value = res.data
                        //     }
                        // })
                    }
                    getIndex()
                    const editAdmin = (row)=>{
                        console.log(row)
                    }
                    common.refresh = ()=>{
                        getIndex()
                    }
                    return {
                        adminList,
                        getTime:common.getTime,
                        editAdmin,
                        common:common
                    }
                }
            })
            common.load(app,false)
            app.mount('#app')
        },
        edit:()=>{
            const {createApp,  ref, onMounted} = Vue
            const app = createApp({
                setup(){
                    const form = ref(Config.row)
                    form.value.password = ''
                    form.value.group_id = Config.group_id
                    const allGroup = ref(Config.allGroup);
                    return{
                        form,
                        common:common,
                        allGroup
                    }
                }
            })
            common.load(app)
            app.mount('#app')
        },
        add:()=>{
            const {createApp,  ref, onMounted} = Vue
            const app = createApp({
                setup(){
                    const form = ref({
                        username:'',
                        password:'',
                        nickname:'',
                        status:1,
                        avatar:'',
                        group_id:'',
                    })
                    const allGroup = ref(Config.allGroup);
                    return{
                        form,
                        common:common,
                        allGroup
                    }
                }
            })
            common.load(app)
            app.mount('#app')
        }
    }
    return Controller
})